﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace TerritoryGame.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class InitCreate3 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "user_levels",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    UserId = table.Column<Guid>(type: "uuid", nullable: false),
                    CurrentLevel = table.Column<int>(type: "integer", nullable: false, defaultValue: 1),
                    CurrentExperience = table.Column<int>(type: "integer", nullable: false, defaultValue: 0),
                    TotalExperience = table.Column<int>(type: "integer", nullable: false, defaultValue: 0),
                    CurrentTitle = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false, defaultValue: "墨痕初绽"),
                    UnlockedTitles = table.Column<List<string>>(type: "jsonb", nullable: false),
                    LastLevelUpTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    IsActive = table.Column<bool>(type: "boolean", nullable: false),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false),
                    CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_user_levels", x => x.Id);
                    table.ForeignKey(
                        name: "FK_user_levels_users_UserId",
                        column: x => x.UserId,
                        principalTable: "users",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_user_levels_UserId",
                table: "user_levels",
                column: "UserId",
                unique: true);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "user_levels");
        }
    }
}
